package cn.hdu.liang.ch04;

import net.jcip.annotations.GuardedBy;

/**
 * 通过一个私有锁来保护状态
 */

class Widget {

}

public class PrivateLock {
    private final Object myLock = new Object();
    @GuardedBy("myLock") Widget widget;

    void someMethod() {
        synchronized (myLock) {
            // Access or modify the state of widget
        }
    }
}
